이 름 : 바다아이
|
조회수 : 7579
짧은 주소 : https://www.bada-ie.com/su/?391591885966
// 만약 http2 사용하시려면go get golang.org/x/net/http2
// 패키지 가져오셔야 합니다.// 아래는 간단한 예제입니다. 잘 다듬어서 쓰세요...package main
import (
"io""net/http""golang.org/x/net/http2"
)
type funcMan func(w http.ResponseWriter, req *http.Request)funchello(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "Hello, world!\n")
}
funcmain() {
mux := http.DefaultServeMux
// 요기다 주소와 함수 이름을 쓰시면 됩니다.
urlMan := map[string]funcMan{
"/hello": hello,
}
for key, value := range urlMan {
mux.HandleFunc(key, value)
mux.HandleFunc(key+"/", value)
}
srv := http.Server{
Addr: ":80",
Handler: mux,
// ErrorLog: logger,// ReadTimeout: 10 * time.Second,// WriteTimeout: 10 * time.Second,// MaxHeaderBytes: 1 << 20,
}
// 에러 처리는 편한대로 알아서 하세요....
err := http2.ConfigureServer(&srv, nil)
err = srv.ListenAndServe()
_ = err
}
|
|
번 호
카테고리
제 목
이름
조회수
Copyright ⓒ 2001.12. bada-ie.com. All rights reserved.
이 사이트는 리눅스에서 firefox 기준으로 작성되었습니다. 기타 브라우저에서는 다르게 보일 수 있습니다.
[ Ubuntu + GoLang + PostgreSQL + Mariadb ]
서버위치 : 오라클 클라우드 춘천 실행시간 : 0.06689 초 to webmaster... gogo sea. gogo sea.